package com.hmdp.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author : Sonic
 * @version : 1.0
 * @createTime : 2024-12-23  17:37
 * @description : Redisson的配置类,返回一个 RedissonClient客户端对象
 */
@Configuration
public class RedissonConfig {

    @Bean
    public RedissonClient redissonClient() {
        // 配置,注意Config导入时来自org.redisson.config.Config;
        Config config = new Config();
        // 单节点模式配置
        config.useSingleServer()
                .setAddress("redis://172.23.171.159:6379")
                .setPassword("123321");
        // 创建RedissonClient对象
        return Redisson.create(config);
    }
}
